package com.collaboration.electron.services;

import com.collaboration.electron.dao.ProductRepository;
import com.collaboration.electron.entities.Product;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Optional;

/**
 * @author pinzi
 * @param
 * @return 无
 */

@Service
public class ProductService {

    @Autowired
    ProductRepository productRepository;

    public static void delete(Optional<Product> theProduct) {
    }

    public List<Product> getAll(){
        return productRepository.findAll();
    }
    public Product save(Product product){
        return productRepository.save(product);
    }

    public List<Product> findAllByUserId(long Id){
        return productRepository.findAllByUserId(Id);
    }

    public Optional<Product> findByProductId(long theId) {
        return productRepository.findById(theId);
    }
    public void delete(){

    }
}
